#pragma once

#include<string>

/**
Basic file handling
*/
class IFile
{
public:

	virtual ~IFile(){};
	/*
	#CreateFile
	Creates a new file or opens an existing one
	#Returns
	If creation fails returns false
	#Params
	sFilename:	The complete name and path of the file to be created
	*/
	virtual bool CreateFile(const char* sFilename) = 0;

	/*
	#OpenFile
	Opens an existing file
	#Returns
	True if opening succeded
	#Params
	sFilename:	Complete path of the file to be opened
	bCreateNew: Create the file if it doesn't exist?
	*/
	virtual bool OpenFile(const char* sFilename, bool bCreateNew = false) = 0;

	 /*
	 #DeleteFile
	 Deletes the file associated with this class instance
	 */
	virtual bool DeleteFile(bool bKeepTextBuffer = false) = 0;

	 /*
	 #GetFilePointer
	 Returns the pointer to the FILE stream
	 -> Deprechated 
	 Now the destructor also does the file opening which makes this pointer obsolete
	 */
	virtual FILE* GetFilePointer() = 0;


	/*
	#GetTextBuffer
	Returns the text buffer of the file associated with this class instance dfgzdstz
	*/
	virtual std::string GetTextBuffer() = 0;

	 /*
	 #FindString
	 Finds the specified string in the text buffer
	 #Returns 
	 The position of the first character of the found string or EOF if the string 
	 could not be found
	 #Params
	 sString:	The string to be searched for
	 */
	 virtual size_t FindString(const char* sString, ...) = 0;

	 /*
	 #Append
	 Appends the specified string to the end of the file
	 #Params
	 sString:	The string to append
	 */
	 virtual void Append(const char* sString, ...) = 0;

	 /*
	 #PushFront
	 Inserts the specified string at the front of the file
	 #Params
	 sString:	String to insert
	 */
	 virtual void PushFront(const char* sString, ...) = 0;

	 /*
	 #EraseFromFile
	 Erases the specified string from the file
	 #Returns
	 False if the string to erase could not be found in the file
	 #Params
	 sString:	String to be erased from the file
	 pos:		Determines the starting point for searching the string
	 */
	 virtual bool EraseFromFile(const char* sString, size_t pos = -1) = 0;

	 /*
	 #Insert
	 Inserts the specified string at the given position to the file
	 #Returns
	 True if the writing succeded
	 #Params
	 sString:	String to be inserted
	 pos:		The pos to be inserted in
	 */
	 virtual bool Insert(size_t pos, const char* sString, ...) = 0;

	 /*
	 #Write
	 Writes the specified string at the given postion and overrides anything that is already there
	 #Returns 
	 True if everything went right
	 #Params
	 sString:	String to be written
	 pos:		The pos to be written in
	 */
	 virtual bool Write( size_t pos, const char* sString, ...) = 0;

	 /*
	 #ReplaceString
	 Replaces a string in the file with the given one. Does not take multiple identical strings into account!
	 #Returns
	 True if everything went right
	 #Params
	 sToReplace:	String that is to be replaced
	 sReplacement:	String that replaces the old one
	 pos:			If the string to replace occurs more that once, specify the beginnig of where to start searching
	 */
	 virtual bool ReplaceString(const char* sToReplace, const char* sReplacement, size_t pos = 0) = 0;
};

